package cn.diancan.vo.manager;


import cn.diancan.util.DateUtil;
import cn.diancan.util.ObjectUtils;
import org.apache.commons.beanutils.BeanUtils;

import cn.diancan.dto.query.PurchaseSaleOrderProductQuery;

import java.util.Date;

public class PurchaseSaleManagerOrderActionVo {


    private Long goodsId; //可无（需检验）
    private Long productId;
    private Integer quantity;//总量


    private String startTime;
    private String endTime;
    private Long shopClerkId;
    private Long firstGoodsCategoryId;
    private Long secondGoodsCategoryId;
    private Integer productSaleStatus;

    private String goodsNumber;
    private String barCode; //条码
    private String outOrderNumber;


    private Integer isStatistics; //1 YES  0 NO
    private Integer statisticsType;//1.ProductId 2.GoodsId
    private Integer byOrderType;//1.clientCreateTime 2.totalQuantityCount 3.
    private Integer byOrderSortType;//1.ASC 2.DESC


    private Integer pageNumber = 1;// 当前页码
    private Integer pageSize = 10;// 每页记录数


    private Integer byTimeOrderType; // 1. 当天  2.昨天  3.7天  4.30天


    private Integer orderStatus; //未审核  1.结算 2.审核
    private Integer orderCategory; //订单分类  //1.堂食  2.外卖

    private Integer payType; //支付方式
    private Integer isPay;   //是否结算 0.  1.是否结算

    private Long mealLocationId;



    public PurchaseSaleOrderProductQuery getQuery() {
        PurchaseSaleOrderProductQuery query = new PurchaseSaleOrderProductQuery();
        try {
            BeanUtils.copyProperties(query, this);
            if (this.isStatistics == null) {
                this.isStatistics = 0;
                query.setIsStatistics(0);
            }
            if (this.statisticsType == null) {
                this.statisticsType = 1;
                query.setStatisticsType(1);
            }
            if (this.byOrderType == null) {
                this.byOrderType = 1;
                query.setByOrderType(1);
            }
            if (this.byOrderSortType == null) {
                this.byOrderSortType = 2;
                query.setByOrderSortType(2);
            }
            query.setPayType(this.payType);
            query.setOrderCategory(this.orderCategory);
            query.setOrderStatus(this.orderStatus);
            query.setMealLocationId(this.mealLocationId);

        } catch (Exception e) {
            e.printStackTrace();
        }
        return query;
    }

    public PurchaseSaleOrderProductQuery getQuery2() {
        PurchaseSaleOrderProductQuery query = new PurchaseSaleOrderProductQuery();
        try {
            BeanUtils.copyProperties(query, this);
            if (this.isStatistics == null) {
                this.isStatistics = 0;
                query.setIsStatistics(0);
            }
            if (this.statisticsType == null) {
                this.statisticsType = 1;
                query.setStatisticsType(1);
            }
            if (this.byOrderType == null) {
                this.byOrderType = 2;
                query.setByOrderType(2);
            }
            if (this.byOrderSortType == null) {
                this.byOrderSortType = 2;
                query.setByOrderSortType(2);
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
        return query;
    }


    public void handleByTimeOrderType() {
          /*if (null == requestVo.getStartTime()) {
                requestVo.setStartTime(DateUtil.currentDate() + " 00:00:00");
            }
            if (null == requestVo.getEndTime()) {
                requestVo.setEndTime(DateUtil.currentDate() + " 23:59:59");
            }*/
        if (ObjectUtils.isBlank(this.getStartTime()) && ObjectUtils.isBlank(this.getEndTime()) && ObjectUtils.isBlank(this.getOutOrderNumber())) {
            this.setByTimeOrderType(1);
        }

        if (null != this.getByTimeOrderType() && !this.getByTimeOrderType().equals(0)) {
            if (this.getByTimeOrderType().equals(1)) {
                this.setStartTime(DateUtil.currentDate() + " 00:00:00");
                this.setEndTime(DateUtil.currentDate() + " 23:59:59");
            } else if (this.getByTimeOrderType().equals(2)) {
                Date date = new Date();
                date = DateUtil.addDay(date, -1);
                this.setStartTime(DateUtil.currentDate(date) + " 00:00:00");
                this.setEndTime(DateUtil.currentDate(date) + " 23:59:59");
            } else if (this.getByTimeOrderType().equals(3)) {
                Date date = new Date();
                Date date2 = DateUtil.addDay(date, -6);
                this.setStartTime(DateUtil.currentDate(date2) + " 00:00:00");
                this.setEndTime(DateUtil.currentDate(date) + " 23:59:59");


            } else if (this.getByTimeOrderType().equals(4)) {
                Date date = new Date();
                Date date2 = DateUtil.addDay(date, -29);
                this.setStartTime(DateUtil.currentDate(date2) + " 00:00:00");
                this.setEndTime(DateUtil.currentDate(date) + " 23:59:59");
            }

        }
    }


    public Long getGoodsId() {
        return goodsId;
    }

    public void setGoodsId(Long goodsId) {
        this.goodsId = goodsId;
    }

    public Long getProductId() {
        return productId;
    }

    public void setProductId(Long productId) {
        this.productId = productId;
    }

    public Integer getQuantity() {
        return quantity;
    }

    public void setQuantity(Integer quantity) {
        this.quantity = quantity;
    }

    public Integer getPageNumber() {
        return pageNumber;
    }

    public void setPageNumber(Integer pageNumber) {
        this.pageNumber = pageNumber;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public String getStartTime() {
        return startTime;
    }

    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }

    public String getEndTime() {
        return endTime;
    }

    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }

    public Long getShopClerkId() {
        return shopClerkId;
    }

    public void setShopClerkId(Long shopClerkId) {
        this.shopClerkId = shopClerkId;
    }

    public Long getFirstGoodsCategoryId() {
        return firstGoodsCategoryId;
    }

    public void setFirstGoodsCategoryId(Long firstGoodsCategoryId) {
        this.firstGoodsCategoryId = firstGoodsCategoryId;
    }

    public Long getSecondGoodsCategoryId() {
        return secondGoodsCategoryId;
    }

    public void setSecondGoodsCategoryId(Long secondGoodsCategoryId) {
        this.secondGoodsCategoryId = secondGoodsCategoryId;
    }


    public Integer getProductSaleStatus() {
        return productSaleStatus;
    }


    public void setProductSaleStatus(Integer productSaleStatus) {
        this.productSaleStatus = productSaleStatus;
    }


    public Integer getIsStatistics() {
        return isStatistics;
    }


    public void setIsStatistics(Integer isStatistics) {
        this.isStatistics = isStatistics;
    }


    public Integer getStatisticsType() {
        return statisticsType;
    }


    public void setStatisticsType(Integer statisticsType) {
        this.statisticsType = statisticsType;
    }


    public Integer getByOrderType() {
        return byOrderType;
    }


    public void setByOrderType(Integer byOrderType) {
        this.byOrderType = byOrderType;
    }


    public Integer getByOrderSortType() {
        return byOrderSortType;
    }


    public void setByOrderSortType(Integer byOrderSortType) {
        this.byOrderSortType = byOrderSortType;
    }


    public String getGoodsNumber() {
        return goodsNumber;
    }


    public void setGoodsNumber(String goodsNumber) {
        this.goodsNumber = goodsNumber;
    }


    public String getBarCode() {
        return barCode;
    }


    public void setBarCode(String barCode) {
        this.barCode = barCode;
    }


    public String getOutOrderNumber() {
        return outOrderNumber;
    }


    public void setOutOrderNumber(String outOrderNumber) {
        this.outOrderNumber = outOrderNumber;
    }


    public Integer getByTimeOrderType() {
        return byTimeOrderType;
    }

    public void setByTimeOrderType(Integer byTimeOrderType) {
        this.byTimeOrderType = byTimeOrderType;
    }

    public Integer getOrderStatus() {
        return orderStatus;
    }

    public void setOrderStatus(Integer orderStatus) {
        this.orderStatus = orderStatus;
    }

    public Integer getOrderCategory() {
        return orderCategory;
    }

    public void setOrderCategory(Integer orderCategory) {
        this.orderCategory = orderCategory;
    }

    public Integer getPayType() {
        return payType;
    }

    public void setPayType(Integer payType) {
        this.payType = payType;
    }

    public Integer getIsPay() {
        return isPay;
    }

    public void setIsPay(Integer isPay) {
        this.isPay = isPay;
    }

    public Long getMealLocationId() {
        return mealLocationId;
    }

    public void setMealLocationId(Long mealLocationId) {
        this.mealLocationId = mealLocationId;
    }
}
